package ali.mathpp;

import ali.point.Point;

/**
 * Created by IntelliJ IDEA.
 * User: aliolci
 * Date: 04/06/11
 * Time: 08:43
 * To change this template use File | Settings | File Templates.
 */
public class MathPp {
    public static boolean aNumberIsBetweenTwoNumbers(float firstNumber, float secondNumber, float numberBetweenTheseTwo){
        return 0>=(firstNumber-numberBetweenTheseTwo) * (secondNumber-numberBetweenTheseTwo);
    }

    public static boolean aPointIsOnTheSameLineWithTwoOtherPoints(Point theOne, Point pole1, Point pole2){
        return 0==( ( (pole2.getYf()-theOne.getYf()) * (theOne.getXf()-pole1.getXf()) )- ( (theOne.getYf()-pole1.getYf()) * (pole2.getXf() - theOne.getXf()) ) );
    }

    public static int aPointIsBetweenTheOtherTwo(Point theOne, Point pole1, Point pole2) {
        if(!aPointIsOnTheSameLineWithTwoOtherPoints(theOne, pole1,pole2)){
            return -1;
        } else {
            if(aNumberIsBetweenTwoNumbers(pole1.getXf(),pole2.getXf(),theOne.getXf()) && aNumberIsBetweenTwoNumbers(pole1.getYf(),pole2.getYf(),theOne.getYf())){
                  return 0;
            }
            else {
                if(pole1.getDistance(theOne)<pole2.getDistance(theOne)){
                    return 1;
                } else {
                    return 2;
                }
            }
        }
    }
}
